//
//  FRQDeleteAccountViewController.m
//  FRQBluetoothKit_Example
//
//  Created by admin on 2023/10/24.
//  Copyright © 2023 xuchunhai. All rights reserved.
//

#import "FRQDeleteAccountViewController.h"
#import "DeleteAccountViews.h"
#import "DeleteSuccessViews.h"
#import "FeedbackViews.h"
#import "FRQFeedbackViewController.h"
@interface FRQDeleteAccountViewController ()
@property (nonatomic,strong) DeleteAccountViews *DeleteAccountView;
@property (nonatomic,strong) DeleteSuccessViews *DeleteSuccessView;
@property (nonatomic,strong) FeedbackViews *FeedbackView;
@end

@implementation FRQDeleteAccountViewController
- (FeedbackViews *)FeedbackView{
    if (nil==_FeedbackView) {
        _FeedbackView=skXibView(@"FeedbackViews");
        [self.view addSubview:_FeedbackView];
        [_FeedbackView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.mas_topLayoutGuide);
            make.bottom.mas_equalTo(self.mas_bottomLayoutGuide);
            make.right.left.mas_equalTo(0);
        }];
    }
    return _FeedbackView;
}
- (DeleteAccountViews *)DeleteAccountView{
    if (nil==_DeleteAccountView) {
        _DeleteAccountView=skXibView(@"DeleteAccountViews");
        [self.view addSubview:_DeleteAccountView];
        [_DeleteAccountView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.mas_topLayoutGuide);
            make.bottom.mas_equalTo(self.mas_bottomLayoutGuide);
            make.right.left.mas_equalTo(0);
        }];
        @weakify(self)
        [[_DeleteAccountView.btnYes rac_signalForControlEvents:(UIControlEventTouchUpInside)] subscribeNext:^(__kindof UIControl * _Nullable x) {
            @strongify(self)
            NSDictionary *dic=@{@"userType":skUser.userType,
                                @"userId":skUser.userId
            };
            [skNetTools skPOSTWithURL:[NSString stringWithFormat:@"%@%@",skURL,@"app/user/delete"] parameters:dic cachePolicy:0 callback:^(id  _Nonnull responseObject, NSError * _Nonnull error) {
                NSLog(@"数据=%@",responseObject);
                skNetModel *model=responseObject;
                if(model.code==200){
                    self.DeleteAccountView.hidden=YES;
                    self.DeleteSuccessView.hidden=NO;
                }else{
                    [SkToast SkToastShow:model.msg];
                }
            }];
            
        }];
        [[_DeleteAccountView.btnNo rac_signalForControlEvents:(UIControlEventTouchUpInside)] subscribeNext:^(__kindof UIControl * _Nullable x) {
            @strongify(self)
            [self dismissViewControllerAnimated:YES completion:^{
                
            }];
        }];
        [[_DeleteAccountView.btnBack rac_signalForControlEvents:(UIControlEventTouchUpInside)] subscribeNext:^(__kindof UIControl * _Nullable x) {
            @strongify(self)
            [self dismissViewControllerAnimated:YES completion:^{
                
            }];
        }];
    }
    return _DeleteAccountView;
}
- (DeleteSuccessViews *)DeleteSuccessView{
    if (nil==_DeleteSuccessView) {
        _DeleteSuccessView=skXibView(@"DeleteSuccessViews");
        [self.view addSubview:_DeleteSuccessView];
        [_DeleteSuccessView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(APP.statusBarHeight);
            make.bottom.mas_equalTo(self.mas_bottomLayoutGuide);
            make.right.left.mas_equalTo(0);
        }];
        @weakify(self)
        [[_DeleteSuccessView.btnFeedback rac_signalForControlEvents:(UIControlEventTouchUpInside)] subscribeNext:^(__kindof UIControl * _Nullable x) {
            @strongify(self)
            FRQFeedbackViewController *view=[[FRQFeedbackViewController alloc] init];
            view.modalPresentationStyle=0;
            [self presentViewController:view animated:YES completion:^{

            }];
//            self.DeleteAccountView.hidden=YES;
//            self.DeleteSuccessView.hidden=YES;
//            self.FeedbackView.hidden=NO;
        }];
    }
    return _DeleteSuccessView;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.DeleteAccountView.hidden=NO;
    self.DeleteSuccessView.hidden=YES;
    // Do any additional setup after loading the view.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
